package com.liu.algorithm.strategy;

/**
 * @author LIU
 * @version 1.0
 * @description: TODO
 * @date 2022/8/25 11:05
 */
public class Sorter {
    public static void  sort (Comparable[] arr){
        for (int i = 0; i < arr.length ; i++) {
            int minValueIndex = i;
            for (int j = i+1; j < arr.length ; j++) {
               minValueIndex = arr[minValueIndex].compareTo(arr[j]) == 1 ? j: minValueIndex;
            }
            swap(arr,i,minValueIndex);
        }
    }

    public static void swap(Comparable[] arr,int i,int j){
        Comparable temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}
